package operation;

import book.Book;
import book.Booklist;

import java.util.Scanner;

public class ReturnOperation implements IOPeration{
        public void work(Booklist booklist){
            System.out.println("归还图书。。。。。");
            System.out.println("请输入要归还的书名");
            Scanner scanner=new Scanner(System.in);
            String bookName=scanner.nextLine();
            int currentSize=booklist.getUsedSize();
            for(int i=0;i<currentSize;i++){
                Book book=booklist.getBook(i);
                if(booklist.getBook(i).equals(bookName)){
                    book.setLend(false);
                    System.out.println("成功归还！");
                    return;
                }
            }
            System.out.println("归还失败");
        }

}
